package com.example.cet4try.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.cet4try.R;

import java.util.ArrayList;
import java.util.List;

public class PageListAdapter extends BaseAdapter {

    private String[] pdata;
    private Context context;

    public PageListAdapter(String[] pdata, Context context) {
        this.pdata = pdata;
        this.context = context;
    }

    @Override
    public int getCount() {
        return pdata.length;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    static class ViewHolder{
        public TextView item1;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view==null){
            holder = new ViewHolder();
            view = LayoutInflater.from(context).inflate(R.layout.p2_list_liem,viewGroup,false);
            holder.item1 = (TextView) view.findViewById(R.id.item0);

            view.setTag(holder);

        }
        else {
            holder = (ViewHolder) view.getTag();
        }
        holder.item1.setText(pdata[i]);

        return view;
    }


}
